package com.tudouji.project.d3.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tudouji.framework.aspectj.lang.annotation.Log;
import com.tudouji.framework.aspectj.lang.enums.BusinessType;
import com.tudouji.project.d3.domain.LogisticRule;
import com.tudouji.project.d3.service.ILogisticRuleService;
import com.tudouji.framework.web.controller.BaseController;
import com.tudouji.framework.web.domain.AjaxResult;
import com.tudouji.common.utils.poi.ExcelUtil;
import com.tudouji.framework.web.page.TableDataInfo;

/**
 * 发货地址配置Controller
 * 
 * @author tudouji
 * @date 2023-10-20
 */
@RestController
@RequestMapping("/d3/logisticrule")
public class LogisticRuleController extends BaseController
{
    @Autowired
    private ILogisticRuleService logisticRuleService;

    /**
     * 查询发货地址配置列表
     */
    @PreAuthorize("@ss.hasPermi('d3:logisticrule:list')")
    @GetMapping("/list")
    public TableDataInfo list(LogisticRule logisticRule)
    {
        startPage();
        List<LogisticRule> list = logisticRuleService.selectLogisticRuleList(logisticRule);
        return getDataTable(list);
    }

    /**
     * 导出发货地址配置列表
     */
    @PreAuthorize("@ss.hasPermi('d3:logisticrule:export')")
    @Log(title = "发货地址配置", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LogisticRule logisticRule)
    {
        List<LogisticRule> list = logisticRuleService.selectLogisticRuleList(logisticRule);
        ExcelUtil<LogisticRule> util = new ExcelUtil<LogisticRule>(LogisticRule.class);
        return util.exportExcel(list, "logisticrule");
    }

    /**
     * 获取发货地址配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('d3:logisticrule:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(logisticRuleService.selectLogisticRuleById(id));
    }

    /**
     * 新增发货地址配置
     */
    @PreAuthorize("@ss.hasPermi('d3:logisticrule:add')")
    @Log(title = "发货地址配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LogisticRule logisticRule)
    {
        return toAjax(logisticRuleService.insertLogisticRule(logisticRule));
    }

    /**
     * 修改发货地址配置
     */
    @PreAuthorize("@ss.hasPermi('d3:logisticrule:edit')")
    @Log(title = "发货地址配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LogisticRule logisticRule)
    {
        return toAjax(logisticRuleService.updateLogisticRule(logisticRule));
    }

    /**
     * 删除发货地址配置
     */
    @PreAuthorize("@ss.hasPermi('d3:logisticrule:remove')")
    @Log(title = "发货地址配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(logisticRuleService.deleteLogisticRuleByIds(ids));
    }
}
